<?php

class dbaCustomer
{

    function dbaCustomer (&$dba)
    {
        $this->dba = &$dba;
    }
    
    function getall()
    {
        $sth = $this->dba->query("select * from ".$this->dba->tableforwarder."_mod_banner_customer order by name;");
        if (is_object($sth))
        {
            $rows = $sth->fetch_rows_Array();
            $sth->free();
            return $rows;
        }
    }

    function insert ($name,$descr)
    {
        return $this->dba->query("insert into ".$this->dba->tableforwarder."_mod_banner_customer (name,descr) values (".$this->dba->quote($name).",".$this->dba->quote($descr).");");
    }
    
    function update ($id,$name,$descr)
    {
        return $this->dba->query("update ".$this->dba->tableforwarder."_mod_banner_customer set name='$name',descr='$descr' where id=$id;");
    }
    
    function get ($id)
    {
        $sth = $this->dba->query("select * from ".$this->dba->tableforwarder."_mod_banner_customer where id=$id;");
        if (is_object($sth))
        {
            $row = $sth->fetch_row_Array();
            $sth->free();
            return $row;
        }
    }
    
    function delete ($id)
    {
        $check = $this->dba->query("delete ".$this->dba->tableforwarder.
            "_mod_banner_customer,".$this->dba->tableforwarder.
            "_mod_banner_banner,".$this->dba->tableforwarder.
            "_mod_banner_subscription from ".$this->dba->tableforwarder.
            "_mod_banner_customer BC,".$this->dba->tableforwarder.
            "_mod_banner_banner BB,".$this->dba->tableforwarder.
            "_mod_banner_subscription BS where BC.id=$id and BB.cust_id=BC.id and " .
            "BS.banner_id=BB.id;");
        $check = $this->dba->query("delete ".$this->dba->tableforwarder.
            "_mod_banner_customer,".$this->dba->tableforwarder.
            "_mod_banner_banner from ".$this->dba->tableforwarder.
            "_mod_banner_customer BC,".$this->dba->tableforwarder.
            "_mod_banner_banner BB where BC.id=$id and BB.cust_id=BC.id;");
        $check = $this->dba->query("delete from ".$this->dba->tableforwarder.
            "_mod_banner_customer BC where BC.id=$id;");
        return $check;
    }
    


}

?>
